<?php

namespace app\common\library\aliyuns;

use AlibabaCloud\SDK\Mts\V20140618\Mts;
use Darabonba\OpenApi\Models\Config;

abstract class Base
{
    protected string $accessKey;
    protected string $accessSecret;
    protected string $regionId;
    protected string $bucket;
    protected string $location;

    public function __construct($config = [])
    {
        if (!$config) {
            $config = get_sys_config('', 'upload');
        }
        $this->accessKey = $config['upload_access_id'];
        $this->accessSecret = $config['upload_secret_key'];
        $this->regionId = ltrim($config['upload_url'], 'oss-');
        $this->bucket = $config['upload_bucket'];
        $this->location = $config['upload_url'];

//        $this->accessKey ="LTAI5tBWB7PEDvNR9SPpAuDn";
//        $this->accessSecret ="8h48lHTghz2VaZtY4ETVUjtBiHe6vx";
//        $this->bucket ="tangccy";
//        $this->location ="oss-cn-shanghai";
//        $this->regionId ="cn-shanghai";

    }

    /**
     * 实例化
     * @param array $config
     * @return static
     */
    public static function getInstance(array $config = []) :static
    {
        return new static($config);
    }
}